//
//  TJCoinNameListController.m
//  Teleport
//
//  Created by xtjun on 2020/6/13.
//  Copyright © 2020 xtjun. All rights reserved.
//

#import "TJCoinNameListController.h"

@interface TJCoinNameListController ()

@property (strong, nonatomic) NSArray *datas;


@end

@implementation TJCoinNameListController

- (void)viewDidLoad {
    [super viewDidLoad];

 
   self.tableView.backgroundColor = UIColor.whiteColor;
    
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.rowHeight = 60;
    [self.tableView registerClass:TJStyle1Cell.self forCellReuseIdentifier:style1Cell];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(KNavBarHight);
        make.left.right.bottom.offset(0);
    }];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.datas.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TJStyle1Cell *cell = [tableView dequeueReusableCellWithIdentifier:style1Cell forIndexPath:indexPath];
    TJCellStyleModel *model = self.datas[indexPath.row];
    cell.model = model;
    cell.selectionStyle = model.hasArrow.boolValue ?  UITableViewCellSelectionStyleDefault : UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    TJCellStyleModel *model = self.datas[indexPath.row];
    
    if (_complete) {
        _complete(model.text, model.identification);
    }
    
    [self.navigationController popViewControllerAnimated:YES];
 
    
}


- (NSArray *)datas {
    if (!_datas) {
        NSArray *arr = @[
            @{
                @"text": @"BTC",
                @"identification": @"1",
                @"hasArrow": @(1),
            },
            @{
                @"text": @"USDT",
                @"identification": @"2",
                @"hasArrow": @(1),
            }
        ];
        
        _datas = [TJCellStyleModel mj_objectArrayWithKeyValuesArray:arr];
    }
    return _datas;
    
}

@end
